<template>
	<n-page>
		<view slot="navbar" class="fixed" style="width: 100%;z-index: 999;">
			<n-status-bar background="linear-gradient(to right, #f43f3b,#ec008c)"></n-status-bar>
			<view>
				<view style="background-image: linear-gradient(to right, #f43f3b,#ec008c);" class="flex-row items-center padding-xl padding-bottom-xl" v-if="token">
					<view class="flex-row flex-1">
						<view class="flex-row margin-left-xs justify-center" style="width: 110rpx;" @click="redirectToLink('/otherpages/member/info/info')">
							<image class="radius-xl	" style="width: 110rpx;height: 110rpx;" 
							:src="memberInfo.headimg ? $util.img(memberInfo.headimg) : $util.getDefaultImage().default_headimg" 
							 @error="memberInfo.headimg = $util.getDefaultImage().default_headimg"
							></image>
						</view>
						
						<view class="flex-1 justify-center margin-left-sm">
							<text class="leading-lg text-xl color-gray-1">{{memberInfo.show_name || '登录 / 注册'}}</text>
							<view class="leading-lg flex-row items-center">
								<text class="text-df" style="color:#eadec4">{{$util.encryptMobile(memberInfo.mobile)}}</text>
								<n-icon v-if="memberInfo.realname" name="profile" color="#eadec4" size="24"></n-icon>
							</view>
						</view>
					</view>
				
					<view v-if="memberInfo.source_member" class="flex-row justify-center b-qrcode round margin-top-xs" @tap="navigateToUrl('/pages/user/share_center')">
						<n-icon class="text-center" name="qrcode" color="$gray-1" size="56" @click="redirectToLink('/otherpages/member/promote/promote')"></n-icon>
					</view>
				</view>
				<view style="background-image: linear-gradient(to right, #f43f3b,#ec008c);" class="flex-row items-center padding-xl padding-bottom-xl" v-if="!token" @click="redirectToLink('/pages/member/index/index')">
					<view class="flex-row flex-1">
						<view class="margin-left-xs" style="width: 110rpx;">
							<image class="radius-xl	" style="width: 110rpx;height: 110rpx;" 
							:src="$util.getDefaultImage().default_headimg"
							></image>
						</view>
						
						<view class="flex-1 justify-center margin-left-sm">
							<text class="text-xl color-gray-1">{{ $lang('loginTpis') }}</text>
						</view>
					</view>
				</view>
				
			</view>
		</view>
		<view slot="body">
			<n-status-bar style="margin-top: 220rpx;"></n-status-bar>
			<view class="flex-row justify-around bg-gray-1 padding-y-sm">
				<view class="flex-direction items-center justify-center" @click="redirectToLink('/otherpages/member/balance/balance')">
					<text class="color-red-6 text-md">{{ (parseFloat(memberInfo.balance) + parseFloat(memberInfo.locked_balance)).toFixed(2) }}</text>
					<text class="text-sm">{{ $lang('balance') }}</text>
				</view>
				<view class="border-right-xs border-gray-4 border-solid" style="border: 0;width: 2rpx;"></view>
				<view class="flex-direction items-center justify-center" @click="redirectToLink('/otherpages/member/point/point')">
					<text class="color-red-6 text-md">{{ parseInt(memberInfo.point) }}</text>
					<text class="text-sm">{{ $lang('point') }}</text>
				</view>
				<view class="border-right-xs border-gray-4 border-solid" style="border: 0;width: 2rpx;"></view>
				<view class="flex-direction items-center justify-center" @click="redirectToLink('/otherpages/member/red_point/red_point')">
					<text class="color-red-6 text-md">{{ parseInt(memberInfo.red_point) }}</text>
					<text class="text-sm">{{ $lang('red_point') }}</text>
				</view>
				<view class="border-right-xs border-gray-4 border-solid" style="border: 0;width: 2rpx;"></view>
				<view class="flex-direction items-center justify-center" @click="redirectToLink('/otherpages/member/junzheng_ticket_rate/junzheng_ticket_rate')">
					<text class="color-red-6 text-md">{{ parseInt(memberInfo.junzheng_ticket) }}</text>
					<text class="text-sm">{{ $lang('common.junzheng_ticket') }}</text>
				</view>
			</view>
			
			<view @click="redirectToLink('/pages/order/list/list')" class="flex-row margin-top-sm justify-center justify-between bg-gray-1 padding-sm border-bottom-xs border-gray-4 border-solid" style="border: 0;">
				<view class="text-sm text-bold">{{ $lang('allOrders') }}</view>
				<view class="text-xs color-gray-6 flex-row items-center">
					<text>{{ $lang('seeAllOrders') }}</text>
					<n-icon class="text-center margin-left-sm" name="right" color="$gray-5" size="28"></n-icon>
				</view>
			</view>
			
			<view class="flex-row justify-around bg-gray-1 padding-y-sm" :style="(token && memberInfo.source_member) ? '' : 'border-bottom:1px solid #E5E5E5;'">
				<view class="flex-direction items-center justify-center" @click="redirectToLink('/pages/order/list/list?status=waitpay')">
					<n-icon class="text-center" name="pay" color="$gray-7" size="52" style="height: 75rpx;"></n-icon>
					<text class="text-sm">{{ $lang('waitPay') }}</text>
					<n-badge :count="orderNum.waitPay" caps-count="99" class="absolute-screen" style="left:50rpx;"></n-badge>
				</view>
				<view class="flex-direction items-center justify-center" @click="redirectToLink('/pages/order/list/list?status=waitsend')">
					<n-icon class="text-center" name="exit" color="$gray-7" size="52" style="height: 75rpx;"></n-icon>
					<text class="text-sm">{{ $lang('readyDelivery') }}</text>
					<n-badge :count="orderNum.readyDelivery" caps-count="99" class="absolute-screen" style="left:50rpx;"></n-badge>
				</view>
				<view class="flex-direction items-center justify-center" @click="redirectToLink('/pages/order/list/list?status=waitconfirm')">
					<n-icon class="text-center" name="goods" color="$gray-7" size="52" style="height: 75rpx;"></n-icon>
					<text class="text-sm">{{ $lang('waitDelivery') }}</text>
					<n-badge :count="orderNum.waitDelivery" caps-count="99" class="absolute-screen" style="left:50rpx;"></n-badge>
				</view>
				<view class="flex-direction items-center justify-center" @click="redirectToLink('/pages/order/list/list?status=waitrate')">
					<n-icon class="text-center" name="evaluate" color="$gray-7" size="52" style="height: 75rpx;"></n-icon>
					<text class="text-sm">{{ $lang('waitEvaluate') }}</text>
					<n-badge :count="orderNum.waitEvaluate" caps-count="99" class="absolute-screen" style="left:50rpx;"></n-badge>
				</view>
				<view class="flex-direction items-center justify-center" @click="redirectToLink('/pages/order/activist/activist')">
					<n-icon class="text-center" name="refund" color="$gray-7" size="52" style="height: 75rpx;"></n-icon>
					<text class="text-sm">{{ $lang('refunding') }}</text>
					<n-badge :count="orderNum.refunding" caps-count="99" class="absolute-screen" style="left:50rpx;"></n-badge>
				</view>
			</view>
			
			<view class="flex-row margin-top-sm justify-center justify-between bg-gray-1 padding-sm border-bottom-xs border-gray-4 border-solid" style="border: 0;">
				<text class="text-sm text-bold">我的微店</text>
				<text class="text-xs color-gray-6"></text>
			</view>
			
			<uni-grid :column="5" :show-border="false" :square="false" class="bg-gray-1">
				<!-- 钱包 -->
				<view @click="redirectToLink('/otherpages/member/wallet/wallet')" >
					<uni-grid-item>
						<n-icon class="text-center" name="pay" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">钱包</text>
					</uni-grid-item>
				</view>
				
				<!-- 权益卡 登录并且有邀请人和归属店铺 -->
				<view  v-if="token && memberInfo.source_member != 0 && memberInfo.belong_shop_id != 0" @click="jumpLevel()">
					<uni-grid-item>
						<n-icon class="text-center" name="vip" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">权益卡</text>
					</uni-grid-item>
				</view>
				
				<!-- 签到 -->
				<view @click="redirectToLink('/otherpages/member/signin/signin')" v-if="addonIsExit.membersignin">
					<uni-grid-item>
						<n-icon class="text-center" name="write" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">签到</text>
					</uni-grid-item>
				</view>
			
				<!-- 优惠券 -->
				<view @click="redirectToLink('/otherpages/member/coupon/coupon')">
					<uni-grid-item>
						<n-icon class="text-center" name="ticket" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">{{ $lang('couponList') }}</text>
					</uni-grid-item>
				</view>
			
				<!-- 我的拼单 -->
				<block v-if="Development">
					<view @click="redirectToLink('/promotionpages/pintuan/my_spell/my_spell')" v-if="addonIsExit.pintuan">
						<uni-grid-item>
							<n-icon class="text-center" name="friend" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
							<text class="text-sm">{{ $lang('mySpellList') }}</text>
						</uni-grid-item>
					</view>
				</block>
			
				
			
				<!-- 我的收藏 -->
				<view @click="redirectToLink('/otherpages/member/collection/collection')">
					<uni-grid-item>
						<n-icon class="text-center" name="favor" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">{{ $lang('myCollection') }}</text>
					</uni-grid-item>
				</view>
			
				<!-- 我的足迹 -->
				<view @click="redirectToLink('/otherpages/member/footprint/footprint')">
					<uni-grid-item>
						<n-icon class="text-center" name="footprint" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">{{ $lang('myTracks') }}</text>
					</uni-grid-item>
				</view>
			
				<!-- 兑换记录 -->
				<block v-if="Development">
					<view @click="redirectToLink('/promotionpages/point/order_list/order_list')" v-if="addonIsExit.pointexchange">
						<uni-grid-item>
							<n-icon class="text-center" name="punch" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
							<text class="text-sm">{{ $lang('exchangeOrder') }}</text>
						</uni-grid-item>
					</view>
				</block>
				
				
				<!-- 核销台 -->
				<view v-if="authInfo.is_verifier" @click="redirectToLink('/otherpages/verification/index/index')">
					<uni-grid-item>
						<n-icon class="text-center" name="taoxiaopu" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">{{ $lang('verification') }}</text>
					</uni-grid-item>
				</view>
			
				<!-- 分销中心 -->
				<block v-if="Development">
					<view @click="redirectToLink('/otherpages/fenxiao/index/index')" v-if="addonIsExit.fenxiao && fenxiaoBasicsConfig && fenxiaoBasicsConfig.level > 0">
						<uni-grid-item>
							<n-icon class="text-center" name="shop" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
							<text class="text-sm">{{ fenxiaoWords.concept + '中心' }}</text>
						</uni-grid-item>
					</view>
				</block>
			
				<!-- 砍价 -->
				<view @click="redirectToLink('/promotionpages/bargain/my_bargain/my_bargain')" v-if="addonIsExit.bargain">
					<uni-grid-item>
						<n-icon class="text-center" name="auction" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">{{ $lang('myBargain') }}</text>
					</uni-grid-item>
				</view>
				
				
				
				<!-- 我的团队-->
				<view @click="redirectToLink('/otherpages/member/my_team/my_team')" v-if="token">
					<uni-grid-item>
						<n-icon class="text-center" name="friendfavor" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">我的推广</text>
					</uni-grid-item>
				</view>
			
				<!-- 归属店铺 -->
				<view @click="redirectToLink('/otherpages/member/belongShop/belongShop')" v-if="token">
					<uni-grid-item>
						<n-icon class="text-center" name="friendadd" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">归属</text>
					</uni-grid-item>
				</view>
			
				<!-- 店铺码 -->
				<view @click="redirectToLink('/otherpages/member/shop_code/shop_code')" v-if="token && is_Shop !== 0">
					<uni-grid-item>
						<n-icon class="text-center" name="barcode" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">店铺码</text>
					</uni-grid-item>
				</view>
				
				<!-- 直播 -->
				<!-- #ifdef APP-PLUS || MP -->
				<view @click="onClickLiveLogin()" v-if="token && 0 && is_liver == 0 && addonIsExit.liveplay" >
					<uni-grid-item>
						<n-icon class="text-center" name="video" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">直播</text>
					</uni-grid-item>
				</view>
				<!-- #endif -->
			
				<!-- 直播间 -->	
				<!-- #ifdef APP-PLUS || MP -->
				<view @click="onClickPlayLogin()" v-if="token && 0 && addonIsExit.liveplay">
					<uni-grid-item>
						<n-icon class="text-center" name="global" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text">直播间</text>
					</uni-grid-item>
				</view>
				<!-- #endif -->
				
				<view @click="redirectToLink('/otherpages/focus_list/focus_list')" v-if="token && 0 && addonIsExit.liveplay">
					<uni-grid-item>
						<n-icon class="text-center" name="favor" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">我的关注</text>
					</uni-grid-item>
				</view>
				
				<view @click="redirectToLink('/otherpages/focus_list/fans_list')"  v-if="token && 0 && is_liver && addonIsExit.liveplay">
					<uni-grid-item>
						<n-icon class="text-center" name="selection" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">我的粉丝</text>
					</uni-grid-item>
				</view>
				<!-- 设置 -->
				<view @click="redirectToLink('/otherpages/member/info/info')" v-if="token">
					<uni-grid-item>
						<n-icon class="text-center" name="settings" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">设置</text>
					</uni-grid-item>
				</view>
			
			</uni-grid>
			
			<view class="flex-row margin-top-sm justify-center justify-between bg-gray-1 padding-sm border-bottom-xs border-gray-4 border-solid" style="border: 0;">
				<text class="text-sm text-bold">我的服务</text>
				<text class="text-xs color-gray-6"></text>
			</view>
			<uni-grid :column="5" :show-border="false" :square="false" class="bg-gray-1">
				<!-- 客服 -->
				<view @click="redirectToLink('/otherpages/chat/room/room?siteId=0')" v-if="addonIsExit.servicer">
					<uni-grid-item>
						<n-icon class="text-center" name="service" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">{{ $lang('Service') }}</text>
					</uni-grid-item>
				</view>
				
				<!-- 消息 -->
				<view @click="redirectToLink('/otherpages/station/list/list')" v-if="stationConfig && stationConfig.is_use == 1">
					<uni-grid-item>
						<n-icon class="text-center" name="notification" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">消息</text>
					</uni-grid-item>
				</view>
				<!-- 我的礼品 -->
				<block v-if="Development">
					<view @click="redirectToLink('/otherpages/member/gift/gift')" v-if="addonIsExit.gift">
						<uni-grid-item>
							<n-icon class="text-center" name="present" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
							<text class="text-sm">{{ $lang('winningRecord') }}</text>
						</uni-grid-item>
					</view>
				</block>
				<!-- 地址管理 -->
				<view @click="redirectToLink('/otherpages/member/address/address')">
					<uni-grid-item>
						<n-icon class="text-center" name="locationlight" color="$volcano-6" size="52" style="height: 85rpx;"></n-icon>
						<text class="text-sm">{{ $lang('receivingAddress') }}</text>
					</uni-grid-item>
				</view>
			
			</uni-grid>
			
			<nsGoodsRecommend ref="goodrecommend"></nsGoodsRecommend>
			<view class="ns-padding-bottom">
				<ns-copy-right></ns-copy-right>
			</view>
			
			<ns-login ref="login"></ns-login>
			<!-- 底部tabBar -->
			<diy-bottom-nav @isBulge="isBulge"></diy-bottom-nav>
			
			
		
			<uni-popup ref="sean_popup" type="center" class="wap-floating">
				<view class="title">
					确定{{poster_msg.user_name}}绑定为你的上级吗?
				</view>
				<view class="img-box">
					<image :src="poster_msg.user_img ? $util.img(poster_msg.user_img) : $util.getDefaultImage().default_headimg" mode=""></image>
				</view>
				<view class="message-box">
					<text>邀请码:</text>
					<text class="tuijian-code">{{poster_msg.invite_code}}</text>
				</view>
				<view class="btn-group">
					<button type="default" class="quxiao" @click="close_popup(1)">再想想</button>
					<button type="default" class="sue" @click="sue_popup()">确定</button>
				</view>
				<!-- <text class="iconfont iconroundclose" @click="closeNum"></text> -->
			</uni-popup>
			<uni-popup ref="sean_popup2" type="center" class="wap-floating">
				<view class="title">
					已经绑定{{poster_msg.user_name}}为你的上级
				</view>
				<view class="img-box">
					<image :src="poster_msg.user_img ? $util.img(poster_msg.user_img) : $util.getDefaultImage().default_headimg" mode=""></image>
				</view>
				<view class="message-box">
					<text>邀请码:</text>
					<text class="tuijian-code">{{poster_msg.invite_code}}</text>
				</view>
				<button type="default" class="sueed" @click="close_popup(2)">确定</button>
				<!-- <text class="iconfont iconroundclose" @click="closeNum"></text> -->
			</uni-popup>
			<to-top v-if="showTop" @toTop="scrollToTopNative()"></to-top>
		</view>
	</n-page>
</template>

<script>
	import uniGrid from '@/components/uni-grid/uni-grid.vue';
	import uniGridItem from '@/components/uni-grid-item/uni-grid-item.vue';
	import diyBottomNav from '@/components/diy-bottom-nav/diy-bottom-nav.vue';
	import nsGoodsRecommend from '@/components/ns-goods-recommend/ns-goods-recommend.vue';
	import toTop from '@/components/toTop/toTop.vue';
	import scroll from '@/common/js/scroll-view.js';
	import nsCopyRight from '@/components/ns-copyright/ns-copyright.vue';
	import fenxiaoWords from 'common/js/fenxiao-words.js';
	import globalConfig from '@/common/js/golbalConfig.js';
	import Config from '@/common/js/config.js'
	 
 
	var sdk = uni.requireNativePlugin('TXMLVB-SdkWX');
	//LVB插件对象
	var sdkwx = uni.requireNativePlugin('TXMLVB-LiveRoom');
	var pusher = uni.requireNativePlugin('TXMLVB-Pusher');
		
	import permision from "@/js_sdk/wa-permission/permission.js"
	
	export default {
		components: {
			uniGrid,
			uniGridItem,
			diyBottomNav,
			nsGoodsRecommend,
			toTop,
			nsCopyRight,
			Config
		},
		data() {
			return {
				token: '',
				memberInfo: {
					mobile: 0,
					balance: 0,
					locked_balance: 0,
					balance_money: 0,
					point: 0,
					red_point: 0,
					junzheng_ticket: 0,

				},
				is_Shop: 0, //是否商家店铺
				couponNum: 0,
				orderNum: {
					waitPay: 0, //待付款
					readyDelivery: 0, //待发货
					waitDelivery: 0, //待收货
					waitEvaluate: 0, // 待评价
					refunding: 0 // 退款中
				},
				isVerification: true,
				copyrightLoad: 0,
				bottom_info: {},
				authInfo: {
					is_verifier: false
				},

				shopTop: false,
				scrollTop: 0,
				shopConfig: null,
				promoterInfo: null,
				withdrawConfig: null,
				fenxiaoBasicsConfig: null,
				Bulge: false,
				stationConfig: null,
				poster_msg: {
					invite_code: '',
					user_img: '',
					user_name: ''
				}, //扫码时二维码里面的信息
				// 直播
				UserID:0,
				UserSig:0,
				is_liver:0,//默认不是  主播
			};
		},
		mixins: [scroll, fenxiaoWords, globalConfig, Config],
		onLoad() {
			
			
			// #ifdef APP-PLUS 
				var licenceURL = Config.licenceURL;
				var licenceKey = Config.licenceKey;
				// // 开启麦克风和摄像头
			 
				// this.requestAndroidPermission('android.permission.CAMERA','android.permission.RECORD_AUDIO')
				sdk.setLicence(licenceURL, licenceKey);
				this.getUserSig()
			// #endif
		},
		async onShow() {
			// 刷新多语言
			this.$langConfig.refresh();

			this.token = uni.getStorageSync('token');

			if (uni.getStorageSync('userInfo')) {
				this.memberInfo = uni.getStorageSync('userInfo');
			}

			if (uni.getStorageSync('authInfo')) {
				this.authInfo = uni.getStorageSync('authInfo');
			}
			
			if (this.token) {
				await this.getMemberInfo();
				this.getOrderNum();
				this.getCouponNum();
				this.checkIsVerifier();
				if (this.addonIsExit.memberwithdraw) {
					this.getWithdrawConfig();
				}
				if (this.addonIsExit.fenxiao) {
					this.getFenxiaoBasicsConfig();
				}
				this.getStationConfig();
			} else {
				this.initInfo();
			}
			this.$forceUpdate();
			this.isShop();
			this.getUserSig()
			this.isLiver()
		},
		methods: {
			sean() {
				uni.scanCode({
					success: (res) => {
						console.log('扫码结果');
						console.log(res);
						if (uni.getStorageSync('token')) {
							let string1 = res.result.split('?');
							let string2 = string1[1].split('=');
							if (string1[0] == '/order/payment/payment') {
								// 待客购买
								let Array1 = string1[1].split('&')
								let Array2 = Array1[1].split('=')
								let Array3 = Array2[1]
								console.log(JSON.parse(Array3))
								let cart_ids = []
								JSON.parse(Array3).forEach(item => {
									cart_ids.push(item.id)
								})
								console.log(cart_ids)
								uni.setStorage({
									key: 'orderCreateData',
									data: {
										cart_ids: cart_ids.toString()
									},
									success: () => {
										this.$util.redirectTo('/pages/order/payment/payment');
										this.isSub = false;
									}
								});
							} else {
								console.log('绑定上级');
								this.poster_msg.invite_code = string2[1]
								this.GetpostMsg(this.poster_msg.invite_code)
							}
						} else {
							// 注册
							this.$util.redirectTo('/pages/login/register/phone_reg?invite_code=' + this.poster_msg.invite_code);
						}
					}
				});
			},
			isBulge(e) {
				this.Bulge = e;
			},
			redirectToLink(url) {
				if (!uni.getStorageSync('token')) {
					this.$refs.login.open(url);
				} else {
					this.$util.redirectTo(url);
				}
			},
			onClickLiveLogin(){
				
				this.$util.redirectTo('/otherpages/member/lives/index/start_live?member_id='+this.memberInfo.member_id);
				// sdkwx.logout();
				// let that =this
				// //主播登录
				// var uid =  this.UserID ;
				// var sig =  this.UserSig ;
				// sdkwx.login({
				// 	sdkAppID:Config.imAppid,//直播的appID
				// 	userID:uid+'',//用户ID
				// 	userName:this.memberInfo.nickname,//用户名称
				// 	userAvatar:this.memberInfo.headimg,//用户头像
				// 	userSig:sig ,//签名，参考腾讯官方文档
					
				// }, function(res){
				// 	console.log(Config.imAppid);
				// 	console.log(res);
				// 	if (res.code == 0) {
				// 		console.log("login success");
				// 		that.$util.redirectTo('/otherpages/member/lives/index/start_live?member_id='+that.memberInfo.member_id);
				// 	} else {
				// 		console.log("login failed! ", "errCode：" + res.code + ", errMsg:" + res.data);
				// 	}
				// });
			},
			onClickPlayLogin() {
				
				
				
				// sdkwx.logout();
				if (!uni.getStorageSync('token')) {
					this.$refs.login.open(url);
				} else {
					uni.navigateTo({
						url:'/otherpages/member/lives/index/room_menu'
					});
					return;
					
					//观众登录
					var uid =  this.UserID ;
					var sig =  this.UserSig ;
					sdkwx.login({
						sdkAppID:Config.imAppid,//直播的appID
						userID:uid+'',//用户ID
						userName:this.memberInfo.nickname,//用户名称
						userAvatar:this.memberInfo.headimg,//用户头像
						userSig:sig //签名，参考腾讯官方文档
					}, function(res){
						
						if (res.code == 0) {
							uni.navigateTo({
								url:'/otherpages/member/lives/index/room_menu'
							});
						} else {
							console.log("login failed! ", "errCode：" + res.code + ", errMsg:" + res.data);
						}
					});
				}
				
				
			},
			getUserSig(){
				let that =  this
				this.$api.sendRequest({
					url: '/api/Memberliveplay/getUserSig',
					data: {},
					success: res => {
						console.log('sig',res);
						uni.setStorageSync('live_uid', res.UserID);
						
						that.UserID = res.UserID
						that.UserSig = res.UserSig
					}
				})
			},
			gotoAppPermissionSetting: function() {
				permision.gotoAppPermissionSetting()
			},
			initInfo() {
				this.token = '';
				this.memberInfo = {
					balance: '0.00',
					locked_balance: '0.00',
					balance_money: '0.00',
					point: 0,
					red_point: 0,
					junzheng_ticket: 0
				};
				this.couponNum = 0;
				this.orderNum = {
					waitPay: 0, //待付款
					readyDelivery: 0, //待发货
					waitDelivery: 0, //待收货
					waitEvaluate: 0, // 待评价
					refunding: 0 // 退款中
				};
				this.authInfo = {
					is_verifier: false
				};
				uni.stopPullDownRefresh();
			},
			// 获取会员基础信息
			async getMemberInfo() {
				let res = await this.$api.sendRequest({
					url: '/api/member/info',
					async: false
				});
				if (res.code >= 0 && res.data) {
					this.token = uni.getStorageSync('token');
					this.memberInfo = res.data;
					uni.setStorageSync('userInfo', this.memberInfo);
				} else {
					this.token = '';
					this.initInfo();
					uni.removeStorageSync('token');
				}
				uni.stopPullDownRefresh();
			},
			// 下拉刷新
			onPullDownRefresh() {
				if (uni.getStorageSync('token')) this.getMemberInfo();
				else this.initInfo();
			},
			// 订单数量
			getOrderNum() {
				this.$api.sendRequest({
					url: '/api/order/num',
					data: {
						order_status: 'waitpay,waitsend,waitconfirm,waitrate,refunding'
					},
					success: res => {
						if (res.code == 0) {
							this.orderNum.waitPay = res.data.waitpay;
							this.orderNum.readyDelivery = res.data.waitsend;
							this.orderNum.waitDelivery = res.data.waitconfirm;
							this.orderNum.waitEvaluate = res.data.waitrate;
							this.orderNum.refunding = res.data.refunding;
						}
					}
				});
			},
			// 优惠券数量
			getCouponNum() {
				this.$api.sendRequest({
					url: '/api/member/couponnum',
					success: res => {
						if (res.code == 0) {
							this.couponNum = res.data;
						}
					}
				});
			},
			checkIsVerifier() {
				this.$api.sendRequest({
					url: '/api/verify/checkisverifier',
					success: res => {
						if (res.data) this.authInfo.is_verifier = true;
						else this.authInfo.is_verifier = false;
						uni.setStorageSync('authInfo', this.authInfo);
					}
				});
			},
			jumpLevel() {
				if (this.token) {
					this.$util.redirectTo('/otherpages/member/level/newlevel');
					// this.$util.redirectTo('/otherpages/member/level/level');
				} else {
					this.$refs.login.open('/pages/member/index/index');
				}
			},
			/**
			 * 获取余额提现配置
			 */
			getWithdrawConfig() {
				this.$api.sendRequest({
					url: '/api/memberwithdraw/config',
					success: res => {
						if (res.code >= 0 && res.data) {
							this.withdrawConfig = res.data;
						}
					}
				});
			},
			/**
			 * 获取分销基本配置
			 */
			getFenxiaoBasicsConfig() {
				this.$api.sendRequest({
					url: '/fenxiao/api/config/basics',
					success: res => {
						if (res.code >= 0) {
							this.fenxiaoBasicsConfig = res.data;
						}
					}
				});
			},
			toLevel() {
				this.$util.r
			},

			/**
			 * 获取站内信配置
			 */
			getStationConfig() {
				this.$api.sendRequest({
					url: '/api/Message/stationConfig',
					success: res => {
						if (res.code >= 0) {
							this.stationConfig = res.data;
						}
					}
				});
			},

			/**
			 * 是否为商家
			 */
			isShop() {
				this.$api.sendRequest({
					url: '/api/member/isShop',
					success: res => {
						if (res.code >= 0) {
							this.is_Shop = res.data.is_shop;
						}
					},
				});
			},
			/**
			 * 是否为主播
			 */
			isLiver() {
				this.$api.sendRequest({
					url: '/api/Memberliveplay/isLiver',
					success: res => {
						if (res.is_liver == 0) {
							this.is_liver = 1;
						}
					},
				});
			}
			
		}
	};
</script>

<style lang="scss">
	.hr-view{padding-top: 1rpx;}
</style>
